package com.xintonghua.bussiness.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.xintonghua.bussiness.R;
import com.xintonghua.bussiness.base.SimpleBaseAdapter;
import com.xintonghua.bussiness.bean.database.SearchHistoryModel;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 作者：wanxianyi
 * 时间：2018/4/1.
 * 包名：com.xintonghua.bussiness.adapter
 */

public class SearchAdapter extends SimpleBaseAdapter<SearchHistoryModel> {

    public SearchAdapter(List<SearchHistoryModel> list, Context context) {
        super(list, context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        SearchViewHolder viewHolder;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.adapter_search, null);
            viewHolder = new SearchViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (SearchViewHolder) convertView.getTag();
        }
        viewHolder.tvSearch.setText(mList.get(position).getKeyword());
        return convertView;
    }

    static class SearchViewHolder {
        @BindView(R.id.tv_search)
        TextView tvSearch;

        public SearchViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
